<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span {
            color: red;
        }
    </style>
</head>
<body>
<a href="http://www.baidu.cn">支付成功<span>5</span>秒钟之后跳转到首页</a>
<script>
let time=5;
var htmlAnchorElement = document.querySelector("a");
let timesetInterval= setInterval(function () {
    time--;
    htmlAnchorElement.innerHTML=`支付成功<span>${time}</span>秒钟之后跳转到首页`
    if (time===0){
        clearInterval(timesetInterval)
        window.location.href="http://www.baidu.cn";
    }
},1000)
</script>
</body>

</html>